const commom = require("./webpack.common");
const { merge } = require("webpack-merge");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");

// 1. merge 通用的配置
module.exports = merge(commom, {
  mode: "production",
  // 8. 打包优化
  optimization: {
    // 模块只导出被使用的成员 [相当于标记枯树叶]
    usedExports: true,
    // 压缩输出结果 [摇掉枯树叶]
    minimize: true,
    // 尽可能合并每一个模块到一个函数中
    concatenateModules: true,
  },
  // 5. 生产环境配置
  plugins: [
    new CleanWebpackPlugin(),
    new CopyWebpackPlugin({
      patterns: ["public"],
    }),
  ],
});
